package top.kaoshanji.p1ch02d;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;

/**
 * 代码清单 p1ch02d-02：MethodHandles#identity的使用示例
 * author kaoshanji
 * ^_^
 * create time 2025/1/3 16:48
 */
public class MethodHandlesExample02 {

    private static final Logger logger = LogManager.getLogger(MethodHandlesExample02.class);

    public static void main(String[] args) throws Throwable {
        logger.info("...代码清单 p1ch02d-02：MethodHandles#identity的使用示例...");

        MethodHandle mh = MethodHandles.identity(String.class);
        String value = (String) mh.invoke("Hello");
        System.out.println(value);

    }

}
